<{include file="public_html/header.html"}>
<{include file="public_html/left_menu.html"}>
    <!-- content starts -->
    <blockquote class="layui-elem-quote"><{$action}></blockquote>

    <fieldset class="layui-elem-field">
        <legend>按条件搜索</legend>
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane1" method="post" action="<{$current_url}>">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <select name="subject_id" id="subject" lay-filter="subject">
                            <option value="0">请选择科目</option>
                            <{foreach from=$subject_list item=sitem}>
                                <option value="<{$sitem.id}>" <{if isset($conditions.subject_id) AND $conditions.subject_id == $sitem.id}>selected<{/if}>><{$sitem.title}></option>
                            <{/foreach}>
                        </select>
                    </div>
                    
                    <div class="layui-inline">
                        <input type="text" name="title" placeholder="章节名称" value="<{if !empty($conditions['title']) }><{$conditions['title']}><{/if}>" class="layui-input">
                    </div>

                    <div class="layui-inline">
                        <button type="submit" class="layui-btn">搜索</button>
                        <a class="layui-btn" href="/subject/add_chapter"><i class="layui-icon"></i> 添加章节</a>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
    <form class="layui-form layui-form-pane1" method="post" delete_action="/subject/delete_chapter" action="/subject/update_sort">
        <table class="layui-table" lay-even lay-skin="row">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>所属科目</th>
                    <th>章节名称</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            <{foreach from=$chapter_list item=item}>
                <tr>
                    <td class="center">
                        <input type="checkbox" name="ids[]" value="<{$item['id']}>" title="<{$item['id']}>">
                    </td>
                    <td class="center"><{$item['sub_title']}></td>
                    <td class="center"><{$item['title']}></td>
                    <td class="center">
                    <input style="width:40px;" name="sort[<{$item['id']}>]" maxlength="4" type="text" value="<{$item['sort']}>" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
                    </td>
                    <td class="center">
                        <a class="layui-btn layui-btn-primary layui-btn-small" href="/subject/edit_chapter/<{$item['id']}>" target="_blank"><i class="layui-icon"></i></a>
                        <a class="layui-btn layui-btn-primary layui-btn-small delete_data" href="/subject/delete_chapter/<{$item['id']}>"><i class="layui-icon"></i></a>
                    </td>
                </tr>
            <{/foreach}>
            <{if $chapter_list|count eq 0}>
                <tr>
                    <td class="center" style=" height:120px; text-align:center;line-height:120px;" colspan="5">
                        赞无数据！
                    </td>
                </tr>
            <{/if}>
            <tr>
                <td class="center" colspan="5">
                    <input type="checkbox" lay-filter="checkbox_all" title="全选">
                    <button id="delete" class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon"></i> 批量删除</button>
                    <input type="submit" class="layui-btn layui-btn-primary layui-btn-small" name="" value="更新排序">
                </td>
            </tr>
            </tbody>
        </table>
    </form>
    <div class="layui-box layui-laypage layui-laypage-default">
        <{$pagination}>
    </div>
<{include file="public_html/footer.html"}>
